package com.crm.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.crm.dao.SysUserMapper;
import com.crm.model.SysUser;

@Service
public class UserService implements IUserService {
	
	@Autowired
	private SysUserMapper sysUserMapper;

	/**
	 * 登陆方法
	 * 1.用户名不存在2.密码错误3.登陆成功
	 */
	public int login(SysUser user) {
		SysUser sysuser = null;
		//根据姓名查找用户信息
		sysuser = sysUserMapper.queryUser(user);
		if(sysuser == null){
			return 1;
		}else if(!(sysuser.getUsrPassword().equals(user.getUsrPassword()))){
			return 2;
		}else{
			return 3;
		}
	}
	
	/**
	 * 查找用户信息
	* @return SysUser
	* @param user
	* @return
	 */
	public SysUser queryUser(SysUser user){
		return sysUserMapper.queryUser(user);
	}
	
}
